#include <iostream>

namespace my_reverse_iterator
{
	template<class Iterator,class Ref,class Ptr>
	struct Reverse_Iterator
	{
		Iterator _it;

		typedef Reverse_Iterator<Iterator, Ref, Ptr> ReverseIterator;

		Reverse_Iterator(Iterator it)
			:_it(it)
		{}

		ReverseIterator operator++()
		{
			_it--;
			return *this;
		}

		ReverseIterator operator--()
		{
			_it++;
			return *this;
		}

		Ref operator*()
		{
			Iterator tmp = _it;
			tmp--;
			return *tmp;
		}

		Ptr operator->()
		{
			return &(operator*());
		}

		bool operator!=(const ReverseIterator& rit)
		{
			return _it != rit._it;
		}
	};

}